


/**
 * @author hnikoue
 *
 */
public class Flight implements Comparable<Flight>{
	private LocalArrTime flightTime = null;
	private String gate;//gate of arrival
	private String flightID;//flight ID
	private int nbOfPassengers = 0;
	private LocalArrTime firstTimeAtImmi = null;
	private String desks = null;
	private int timeSpentAtImmi = 0;
	private double processingRate;
	private int tagID;
	

	public String toString(){
		String flightDescription = null;
		if(flightTime != null){
			flightDescription = flightID+", "+gate+", "+ Integer.toString(getNbOfPassengers())+", " + firstTimeAtImmi + ", " + Integer.toString(timeSpentAtImmi);
		}else{
			flightDescription = flightID+", "+gate+", "+ flightTime;
		}
		return flightDescription;
		
	}

	public Flight(String flightID2, String gate2, LocalArrTime currentTime) {
		setFlightID(flightID2);
		gate = gate2;
		flightTime = currentTime;
		setFirstTimeAtImmi(flightTime);
	}
	public Flight(String flightID2, String gate2, int nbPAX,LocalArrTime startTimeImmi, String desksSeq,int timeAtImmi,double rate){
		setFlightID(flightID2);
		gate = gate2;
		setNbOfPassengers(nbPAX);
		setDesks(desksSeq);
		setFirstTimeAtImmi(startTimeImmi);
		flightTime = startTimeImmi;
		setProcessingRate(rate);
		setTimeSpentAtImmi(timeAtImmi);
	}

	public LocalArrTime getTime(){
		return flightTime;
	}
	
	public void setTime(String dateTime){
		flightTime = new LocalArrTime(dateTime);
	}
	public void setTime(int day, int month, int year){
		flightTime = new LocalArrTime(day,month,year);
	}
	
	public void setTime(int day,int month,int year,int hour, int minute,int seconds){
		flightTime = new LocalArrTime(day,month,year,hour,minute,seconds);
	}
	
	public String getGate(){
		return gate;
	}

	public int compareTo(Flight arg0) {
		int result;
			if(flightTime ==null){
				result = firstTimeAtImmi.compareTo(arg0.getTime());
			}else{
				result = flightTime.compareTo(arg0.getTime());
			}
		return result;
	}


	/**
	 * @return the flightID
	 */
	public String getFlightID() {
		return flightID;
	}


	/**
	 * @param flightID the flightID to set
	 */
	public void setFlightID(String flightID) {
		this.flightID = flightID;
	}
	/**
	 * @return the nbOfPassengers
	 */
	public int getNbOfPassengers() {
		return nbOfPassengers;
	}
	/**
	 * @param nbOfPassengers the nbOfPassengers to set
	 */
	public void setNbOfPassengers(int nbOfPassengers) {
		this.nbOfPassengers = nbOfPassengers;
	}
	/**
	 * @return the firstTimeAtImmi
	 */
	public LocalArrTime getFirstTimeAtImmi() {
		return firstTimeAtImmi;
	}
	/**
	 * @param firstTimeAtImmi the firstTimeAtImmi to set
	 */
	public void setFirstTimeAtImmi(LocalArrTime firstTimeAtImmi) {
		this.firstTimeAtImmi = firstTimeAtImmi;
	}
	/**
	 * @return the desks
	 */
	public String getDesks() {
		return desks;
	}
	/**
	 * @param desks the desks to set
	 */
	public void setDesks(String desks) {
		this.desks = desks;
	}
	/**
	 * @return the timeSpentAtImmi
	 */
	public int  getTimeSpentAtImmi() {
		return timeSpentAtImmi;
	}
	/**
	 * @param timeSpentAtImmi the timeSpentAtImmi to set
	 */
	public void setTimeSpentAtImmi(int timeSpentAtImmi) {
		this.timeSpentAtImmi = timeSpentAtImmi;
	}
	/**
	 * @return the processingRate
	 */
	public double getProcessingRate() {
		return processingRate;
	}
	/**
	 * @param processingRate the processingRate to set
	 */
	public void setProcessingRate(double processingRate) {
		this.processingRate = processingRate;
	}
	
	public void updateTimeAtImmi(LocalArrTime newTime){
		int timeInS;
		
		timeInS = newTime.compareTo(firstTimeAtImmi);
		if(timeInS>0){
			timeSpentAtImmi = timeInS; 
		}else{
			firstTimeAtImmi = newTime;
			timeSpentAtImmi = timeSpentAtImmi - timeInS;
		}
	}

	/**
	 * @return the tagID
	 */
	public int getTagID() {
		return tagID;
	}

	/**
	 * @param tagID the tagID to set
	 */
	public void setTagID(int tagID) {
		this.tagID = tagID;
	}





}
